package com.wing.product.controller.admin;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wing.common.utils.PageResult;
import com.wing.product.model.entity.ProductCategory;
import com.wing.product.model.response.ProductPlanningTreeVo;
import com.wing.product.model.response.ProductPlanningVo;
import com.wing.purchase.model.entity.SupplierCategory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 产品规划
 * @version 1.1.0
 * @Author hz
 * @Date 2024-09-04 11:10
 **/
@Slf4j
@Validated
@Api(value = "Admin-产品工程-产品规划", tags = "#/product/planning/productPlanning")
@RestController("productPlanningController")
@RequestMapping("product/admin/planning/productPlanning")
public class ProductPlanningController {

    @ApiOperation(value = "查询客户产品规划列表", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
    })
    @GetMapping("/list")
    public PageResult<ProductPlanningVo> list(
            @RequestParam(defaultValue = "1") Integer page
            ,@RequestParam(defaultValue = "10") Integer limit
            ,@RequestParam(defaultValue = "create_time") String sort
            ,@RequestParam(defaultValue = "asc") String order
            ,String name
    ) {
        Page<ProductPlanningVo> pg = new Page<>(page, limit);
        List<ProductPlanningVo> productPlanningVos = new ArrayList<>();
        ProductPlanningVo productPlanningVo = new ProductPlanningVo();
        productPlanningVo.setCusProductCode("CusProductCode");
        productPlanningVo.setCusProductId("PS1008611");
        productPlanningVo.setCusProductFigure("CusProductFigure");
        productPlanningVo.setCustomerCode("IEQ-AD-01");
        productPlanningVo.setCusProductType("CusProductType");
        productPlanningVo.setId(100L);
        productPlanningVo.setCusProductFigureId("111");
        productPlanningVo.setCreator("admin|admin");
        productPlanningVo.setCusProductName("CusProductName");
        productPlanningVo.setAssemblyNatureId(11111111L);
        productPlanningVo.setAssemblyNature("套件");
        productPlanningVo.setProductNature("ProductNature");
        productPlanningVo.setCusProductFigureId("111");
        productPlanningVo.setOrderCode("DD1008611");
        productPlanningVo.setOrderId(11111112L);
        productPlanningVo.setProductStatus("规划中");
        productPlanningVo.setProductStatus("规划中");
        productPlanningVo.setRemark("备注！");
        productPlanningVo.setCreateTime(LocalDateTime.now());
        productPlanningVo.setGivenPlanningTime(LocalDateTime.of(2024,9,11,12,59));
        productPlanningVos.add(productPlanningVo);
        pg.setRecords(productPlanningVos);
        return new PageResult<>(pg.getRecords(), productPlanningVos.size());
    }

}
